From 83e445d75e349bd41a0aec3f78a87b72460f1572 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Thu, 5 Oct 2006 14:53:29 +0100 Subject: [PATCH] Import the Xend portion of xen-unstable changeset 11704:a95dfbc8dca8ecddcb9be51d78f446b0fa461892. [HVM/vncserver] Implement a 'vnclisten' option to limit the interface that the VNC server from qemu listens on. Defaults to only listen on 127.0.0.1 The old behaviour (listen on all interfaces) can be restored, by - changing the system-wide default in /etc/xen/xend-config.sxp by adding: (vnc-listen '0.0.0.0') - changing individual domain config files by adding: vnclisten="0.0.0.0" Also allows specifying the hostname associated with an interface to limit to that interface. Signed-off-by: Daniel P. Berrange --- tools/python/xen/xend/XendRoot.py | 6 ++++++ tools/python/xen/xend/image.py | 5 +++++ tools/python/xen/xm/create.py | 9 +++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xend/XendRoot.py b/tools/python/xen/xend/XendRoot.py index 927e5ed537..3906cac6c7 100644 --- a/tools/python/xen/xend/XendRoot.py +++ b/tools/python/xen/xend/XendRoot.py @@ -93,6 +93,9 @@ class XendRoot: dom0_vcpus_default = '0' + """Default interface to listen for VNC connections on""" + xend_vnc_listen_default = '127.0.0.1' + """Default session storage path.""" xend_domains_path_default = '/var/lib/xend/domains' @@ -281,6 +284,9 @@ class XendRoot: def get_console_limit(self): return self.get_config_int('console-limit', 1024) + def get_vnclisten_address(self): + return self.get_config_value('vnc-listen', self.xend_vnc_listen_default) + def instance(): """Get an instance of XendRoot. Use this instead of the constructor. diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index d31467311a..ee131d9841 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -366,6 +366,11 @@ class HVMImageHandler(ImageHandler): else: ret += ['-vnc', '%d' % vncdisplay] ret += ['-k', 'en-us'] + vnclisten = sxp.child_value(config, 'vnclisten') + if not(vnclisten): + vnclisten = xen.xend.XendRoot.instance().get_vnclisten_address() + if vnclisten: + ret += ['-vnclisten', vnclisten] return ret def createDeviceModel(self): diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index aab0d930ec..933ef84f5c 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -419,6 +419,10 @@ gopts.var('vncdisplay', val='', fn=set_value, default=None, use="""VNC display to use""") +gopts.var('vnclisten', val='', + fn=set_value, default=None, + use="""Address for VNC server to listen on.""") + gopts.var('vncunused', val='', fn=set_bool, default=1, use="""Try to find an unused port for the VNC server. @@ -650,8 +654,9 @@ def configure_hvm(config_image, vals): """ args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb', 'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw', - 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display', - 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ] + 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten', + 'sdl', 'display', 'xauthority', + 'acpi', 'apic', 'usb', 'usbdevice' ] for a in args: if (vals.__dict__[a]): config_image.append([a, vals.__dict__[a]]) -- 2.30.2